package org.workstream;

import java.util.HashMap;

import org.workstream.driver.LocalDriver;

public class LDriverManage {
	private static HashMap<String,LocalDriver> driverReg;
	static{
		driverReg = new HashMap<String,LocalDriver>();
	};
	public static LocalDriver GetDriver(String dname){
		return driverReg.get(dname);
	}
	public static synchronized LocalDriver CreateDriver(String dname){
		if(driverReg.get(dname) != null)
			return null;
		LocalDriver ld = new LocalDriver();
		driverReg.put(dname, ld);
		return ld;
	}
	public static synchronized boolean RegDriver(String dname,LocalDriver ld){
		if(driverReg.get(dname) != null)
			return false;
		driverReg.put(dname, ld);
		return true;
	}
	public static synchronized boolean RemoveDriver(String dname){
		if(driverReg.get(dname) == null)
			return false;
		driverReg.remove(dname);
		return true;
	}
}
